#pip install pyqt5
import sys
from PyQt5 import QtWidgets, QtGui, QtCore
class CoolHelloWindow(QtWidgets.QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    # 窗口的标题、大小和背景颜色
    def initUI(self):
        self.setWindowTitle('Hello OpenHarmony - Cool PyQt5 Effect')
        self.setGeometry(100, 100, 800, 400)
        self.setStyleSheet("background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1, stop:0 #ff7f50, stop:1 #1e90ff);")

        # Hello OpenHarmony
        self.label = QtWidgets.QLabel(self)
        self.label.setText('✨🌸 Hello OpenHarmony 🌸✨')
        self.label.setGeometry(QtCore.QRect(10, 100, 800, 200))
        
        # 字体
        font = QtGui.QFont('Comic Sans MS', 20, QtGui.QFont.Bold)
        self.label.setFont(font)
        
        # 渐变效果
        gradient = QtGui.QLinearGradient(0, 0, 1, 0)
        gradient.setCoordinateMode(QtGui.QGradient.ObjectBoundingMode)
        gradient.setColorAt(0.0, QtGui.QColor('#ff1493'))  # 深粉红
        gradient.setColorAt(1.0, QtGui.QColor('#00bfff'))  # 深天蓝

        # 使用渐变效果画刷
        brush = QtGui.QBrush(gradient)
        palette = self.label.palette()
        palette.setBrush(QtGui.QPalette.WindowText, brush)
        self.label.setPalette(palette)

        # 文本对齐方式
        self.label.setAlignment(QtCore.Qt.AlignCenter)

        self.show()

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    window = CoolHelloWindow()
    sys.exit(app.exec_())
